#ifndef NETWORKTEST_H
#define NETWORKTEST_H

#include <QWidget>
#include <QTcpServer>
#include <QTcpSocket>
#include <QUdpSocket>
#include <QMessageBox>
#include <QPixmap>
#include <QString>
#include <QNetworkDatagram>
#include <QAbstractSocket>
#include <QNetworkInterface>
#include <QRandomGenerator>

QT_BEGIN_NAMESPACE
namespace Ui { class NetWorkTest; }
QT_END_NAMESPACE

class NetWorkTest : public QWidget
{
    Q_OBJECT

public:
    NetWorkTest(QWidget *parent = nullptr);
    ~NetWorkTest();

    QTcpServer *tcpServer;
    QTcpSocket *tcpSockect;
    QUdpSocket *udpSockect;



    int tcpServerInit();
    int tcpClientInit();
    int udpInit();

    void tcpServerClose();
    void tcpClientClose();
    void udpClose();

private slots:
    int on_btOpen_clicked();
    int on_btClose_clicked();
    int on_btSend_clicked();
    void slot_cbModeChanged();
    void slot_tcpServer_newConnection();
    void slot_tcp_readyRead();
    void slot_tcpClient_Connected();
    void slot_udp_readyRead();
    void slot_tcpSocketErr();
    void slot_udpSocketErr();

private:
    void setAllLocalIP();
    void tcpSend();
    void udpSend();
    bool connected;
    void setConnectIcon();
    void setConnectIcon(bool a);
    void setModeUI();
    Ui::NetWorkTest *ui;
};
#endif // NETWORKTEST_H
